/** 后台-配置列表页面 **/
import Http from '@/common/js/http.js'
import EduMessage from '@/common/js/message.js';

export default {
  namespaced: true,
  state: {
    noReadCount: 0
  },
  mutations: {
    SET_NO_READ_COUNT: (state, count) => {
      state.noReadCount = count
    }
  },
  actions: {
    loadMessageCount({
      commit
    }) {
      Http.get(
        '/admin/system/message/count', {},
        response => {
          commit('SET_NO_READ_COUNT', response.data.no_read_count)
        },
        error => {
          EduMessage.error(error.msg);
        },
        false
      );
    },
    setNoReadCount({
      commit
    }, count) {
      commit('SET_NO_READ_COUNT', count)
    },
    setAllRead({
      commit
    }) {
      commit('SET_NO_READ_COUNT', 0)
    }

  },
  getters: {
    noReadCount: state => state.noReadCount
  }
}
